export function set (key, value) {
  if (value) {
    window.localStorage.setItem(key, JSON.stringify(value))
  } else {
    localStorage.removeItem(key)
  }
}

export function get (key) {
  let item = window.localStorage.getItem(key)
  if (!item || item === 'undefined') {
    return undefined
  }
  let result = JSON.parse(item)
  if (!result) {
    return undefined
  }
  return result
}

// const db = {
//   save(key, value) {
//     localStorage.setItem(key, JSON.stringify(value))
//   },
//   get(key, defaultValue = {}) {
//     return JSON.parse(localStorage.getItem(key)) || defaultValue
//   },
//   remove(key) {
//     localStorage.removeItem(key)
//   },
//   clear() {
//     localStorage.clear()
//   }
// }
//
// export default db

